package dp.danhngon.danhngoncuocsong;

import java.util.ArrayList;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import dp.danhngon.danhngoncuocsong.R;

//5.Xay dung adapter
public class MyAdapter extends ArrayAdapter<Content>{
	private Context mContext;
	private ArrayList<Content> array;
	
	public MyAdapter(Context context, int textViewResourceId, ArrayList<Content> arrays) {
		super(context, textViewResourceId, arrays);
		
		this.mContext=context;
		this.array=arrays;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View contentView=convertView;
		if(contentView==null){
			contentView=new LayoutItem(mContext);
			
		}
		Content content=array.get(position);
		if(content!=null){
			TextView txtSubTitle=((LayoutItem)contentView).txtSubTile;
			TextView txtSubContent =((LayoutItem)contentView).txtSubContent;
			
			
			txtSubTitle.setText(content.title);
			txtSubContent.setText(content.content);
			
		}
		return contentView;
	}
}
